package cn.sciento.farm.devicemanager.gateway.lorawan.grpc.impl;

import cn.sciento.farm.devicemanager.gateway.lorawan.grpc.GrpcConstant;
import cn.sciento.farm.devicemanager.gateway.lorawan.grpc.InternalService;
import cn.sciento.farm.devicemanager.lorawan.InternalServiceGrpc;
import cn.sciento.farm.devicemanager.lorawan.LoginRequest;
import cn.sciento.farm.devicemanager.lorawan.LoginResponse;
import io.grpc.Channel;
import net.devh.boot.grpc.client.inject.GrpcClient;
import org.springframework.stereotype.Service;

/**
 * @author wumu
 * @version V1.0
 * @date 9/15/18
 * @time 7:24 PM
 */
@Service
public class InternalServiceImpl implements InternalService {


    @GrpcClient(GrpcConstant.GRPC_NAME)
    private Channel serverChannel;


    @Override
    public LoginResponse login(LoginRequest request) {
        InternalServiceGrpc.InternalServiceBlockingStub stub = InternalServiceGrpc.newBlockingStub(serverChannel);
        LoginResponse response = stub.login(request);
        return response;
    }

}
